#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "serialportcontroller.h"
#include "communicationlogger.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    
    // Set application properties for QSettings
    app.setOrganizationName("FocusHost");
    app.setOrganizationDomain("focushost.local");
    app.setApplicationName("focusHost");

    // Register QML types
    qmlRegisterType<SerialPortController>("focusHost", 1, 0, "SerialPortController");
    qmlRegisterType<CommunicationLogger>("focusHost", 1, 0, "CommunicationLogger");

    QQmlApplicationEngine engine;
    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreationFailed,
        &app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);
    engine.loadFromModule("focusHost", "Main");

    return app.exec();
}
